#include <iostream>
#include <vector>
#include <cstring>
#include <queue>
using namespace std;
const int N=1e5+10;
const int MOD=1e5+3;


vector<int> edge[N];
int dist[N];
int cnt[N];
int n,m;
void bfs()
{
	memset(dist,0x3f3f3f,sizeof(dist));
	memset(cnt,0,sizeof(cnt));
	cnt[1]=1;
	dist[1]=0;
	queue<int> q;
	q.push(1);
	while(q.size())
	{
		int t=q.front();
		q.pop();
		for(auto&x:edge[t])
		{
			if(dist[x]==dist[t]+1)
			{
				cnt[x]=(cnt[x]+cnt[t])%MOD;
			}
			else if(dist[x]>dist[t]+1)
			{
				cnt[x]=cnt[t];
				dist[x]=dist[t]+1;
				q.push(x);
			}
		}
	}
	
}
int main()
{
	cin>>n>>m;
	for(int i=0;i<m;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		edge[x].push_back(y);
		edge[y].push_back(x);
	}
	bfs();
	for(int i=1;i<=n;i++)
		cout<<cnt[i]<<endl;
		
	
	return 0;
}
